<template>
  <div>
   <template>
  <el-table
    :data="loan_approval"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="id_loan"
      label="编号"
      width="150">
    </el-table-column>
    <el-table-column
      prop="enterprise_id"
      label="企业信息"
      width="120">
    </el-table-column>
    <el-table-column
      prop="audit_id"
      label="审核人"
      width="120">
    </el-table-column>
    <el-table-column
      prop="state_id"
      label="状态信息"
      width="120">
      <template slot-scope="scope">
         <span style="margin-left: 10px" v-if="scope.row.state_id==true">一审核通过</span>
          <span style="margin-left: 10px" v-if="scope.row.state_id==false">一审核未通过</span>
      </template>
    </el-table-column>
    <el-table-column
      prop="credit_id"
      label="授信结果"
      width="120">
      <template slot-scope="scope">
         <span style="margin-left: 10px" v-if="scope.row.credit_id==true">二审核通过</span>
          <span style="margin-left: 10px" v-if="scope.row.credit_id==false">二审核未通过</span>
      </template>
    </el-table-column>
     <el-table-column
      prop="state_audit"
      label="状态"
      width="120">
       <template slot-scope="scope">
         <span style="margin-left: 10px" v-if="scope.row.state_audit==true">已处理</span>
          <span style="margin-left: 10px" v-if="scope.row.state_audit==false">未处理</span>
      </template>
    </el-table-column>
     <el-table-column
      prop="opinion"
      label="意见"
      width="300">
    </el-table-column>
    
    <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">通过审核</el-button>
        <el-button @click="deleteClick(scope.row)" type="text" size="small">不通过审核</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
  </div>
</template>

<script>
export default {
  methods: {
      handleClick(row) {      
         this.$axios
        .put("http://localhost:8800/loanapprovals/update/"+row.id_loan, this.loan_approval)
        .then((resp) => {
          console.log(row);
                     
        });
       
      },
      getAllloanApproval(){
         this.$axios
        .get("http://localhost:8800/loanapprovals/allLoanApproval", this.loan_approval)
        .then((resp) => {
          console.log(resp.data);
          this.loan_approval=resp.data;                 
        });  
      },
      deleteClick(row){       
        this.$axios
        .delete("http://localhost:8800/loanapprovals/delete/"+row.id_loan)
        .then((resp) => { 
          this.getAllloanApproval();               
        }); 
        
      }
    },
   created(){
     this.getAllloanApproval();
        
    },
    data() {
      return {
        loan_approval: [{
          id_loan: '',
          enterprise_id: '',
          audit_id: '',
          state_id: '',
          credit_id: '',
          state_audit:'',
          opinion:''
        }]
      }
    },
    
}
</script>

<style>
</style>